﻿namespace MicroCloud.Audit
{
    [Dependency(ServiceLifetime.Scoped, AddSelf = true)]
    public class AuditOperationStore
    {
        private readonly IRepository<AuditOperation, long> auditOperationRepository;

        /// <summary>
        /// 初始化一个Article存储功能 <see cref="AuditEntityStore"/> 的新实例
        /// </summary>
        public AuditOperationStore(IRepository<AuditOperation, long> auditOperationRepository)
        {
            this.auditOperationRepository = auditOperationRepository;
        }

        public IQueryable<AuditOperation> AuditOperations => auditOperationRepository.Query();

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entities">数据实体</param>
        /// <returns></returns>
        public OperationResult Delete(params AuditOperation[] entities)
        {
            Check.NotNull(entities, nameof(entities));

            return auditOperationRepository.Delete(entities);
        }

        /// <summary>
        /// 异步删除
        /// </summary>
        /// <param name="keys">数据实体编号</param>
        public Task<OperationResult> DeleteAsync(long[] keys)
        {
            Check.NotNull(keys, nameof(keys));

            return auditOperationRepository.DeleteAsync(keys);
        }

    }
}
